//
//  NSDate+XHLKit.h
//  XHLKit
//
//  Created by qinyulun on 16/6/18.
//  Copyright © 2016年 leTian. All rights reserved.
//

#import <Foundation/Foundation.h>

typedef NS_ENUM(NSUInteger, DateType) {
    DateTypeOne, //  2016/05/09样式
    DateTypeTwo, //  2016/5/9样式
    DateTypeThree, //  16:53:28样式 24小时制
    DateTypeFour, //  4:53:28样式 12小时制
    DateTypeFive, //  2016/05/09 16:53:28样式 24小时制
    DateTypeSix, //  2016/5/9 16:53样式 24小时制
    DateTypeSeven, //  2016-05-09样式
    DateTypeEight, //  2016-5-9样式
    DateTypeNine, //  16:53样式 24小时制
    DateTypeTen,  //  4:53样式 12小时制
    DateTypeEleven, //  3-5 4:53样式 12小时制
    DateTypeTwelve, //  3-5 16:53样式 24小时制
    DateTypeThirteen, //  3月5日 16:53样式 24小时制
};

struct XHLDateInformation {
    NSInteger day;
    NSInteger month;
    NSInteger year;
    
    NSInteger weekday;
    
    NSInteger minute;
    NSInteger hour;
    NSInteger second;
};
typedef struct XHLDateInformation XHLDateInformation;

@interface NSDate (XHLKit)

/**
 *  根据后台数据返回对应格式时间字符串  @"yyyy-MM-dd HH.mm.ss.sss"默认源时间字符串的格式
 *
 *  @param timeString 后台返回时间
 *  @param formatter  格式化时间
 *
 *  @return 格式化之后的时间
 */
+ (NSString*)stringWithTime:(NSString *)timeString formatter:(NSString *)formatter;

/**
 *  根据后台数据返回对应格式时间字符串
 *
 *  @param timeString 后台返回时间
 *  @param dateType  格式化类型
 *
 *  @return 格式化之后的时间
 */
+ (NSString*)stringWithTime:(NSString *)timeString dateType:(DateType )dateType;


//  2016090717300000
+ (NSString *)timeStringImg:(NSDate *)timeImg;

// 判断是今天还是明天
+ (NSString*)staticCompareDate:(NSString *)date;
// 判断是星期几(周一，周二，周日，周六)
+ (NSString*)staticWeekDayStr:(NSString *)date;

// 判断今天，昨天，还是星期几
+ (NSString*)combinationCompareData:(NSString*)time;

// 判断是几月
+ (NSString*)staticYearDayStr:(NSString *)date;


/**
 *  Create a NSDate with the yesterday date
 *
 *  @return Return a NSDate with the yesterday date
 */
+ (NSDate *)yesterday;

/**
 *  Get the month from today
 *
 *  @return Return the month
 */
+ (NSDate *)month;

/**
 *  Get the month from self
 *
 *  @return Return the month
 */
- (NSDate *)month;

/**
 *  Get the weekday number from self
 *
 *  @return Return weekday number
 *  [1 - Sunday]
 *  [2 - Monday]
 *  [3 - Tuerday]
 *  [4 - Wednesday]
 *  [5 - Thursday]
 *  [6 - Friday]
 *  [7 - Saturday]
 */
- (NSInteger)weekday;

- (NSDate *)timelessDate;

/**
 *  Get the weekday as a localized string from self
 *
 *  @return Return weekday as a localized string
 *  [1 - Sunday]
 *  [2 - Monday]
 *  [3 - Tuerday]
 *  [4 - Wednesday]
 *  [5 - Thursday]
 *  [6 - Friday]
 *  [7 - Saturday]
 */
- (NSString *)dayFromWeekday;

/**
 *  Compare self with another date
 *
 *  @param anotherDate The another date to compare as NSDate
 *
 *  @return Return YES if is same day, NO if not
 */
- (BOOL)isSameDay:(NSDate *)anotherDate;

/**
 *  Get the months number between self and another date
 *
 *  @param toDate The another date
 *
 *  @return Return the months between the two dates
 */
- (NSInteger)monthsBetweenDate:(NSDate *)toDate;

/**
 *  Get the days number between self and another date
 *
 *  @param toDate The another date
 *
 *  @return Return the days between the two dates
 */
- (NSInteger)daysBetweenDate:(NSDate *)toDate;

/**
 *  Return if self is today
 *
 *  @return Return if self is today
 */
- (BOOL)isToday;

/**
 *  Add days to self
 *
 *  @param days The number of days to add
 *
 *  @return Return self by adding the gived days number
 */
- (NSDate *)dateByAddingDays:(NSUInteger)days;

/**
 *  Create an NSDate with other two NSDate objects.
 *  Taken from the first date: day, month and year.
 *  Taken from the second date: hours and minutes.
 *
 *  @param aDate The first date for date
 *  @param aTime The second date for time
 *
 *  @return Return the created NSDate
 */
+ (NSDate *)dateWithDatePart:(NSDate *)aDate andTimePart:(NSDate *)aTime;

/**
 *  Get the month string from self
 *
 *  @return Return the month string
 */
- (NSString *)monthString;

/**
 *  Get the year string from self
 *
 *  @return Return the year string
 */
- (NSString *)yearString;

/**
 *  Get the month as a localized string from the given month number
 *
 *  @param month The month to be converted in string
 *  [1 - January]
 *  [2 - February]
 *  [3 - March]
 *  [4 - April]
 *  [5 - May]
 *  [6 - June]
 *  [7 - July]
 *  [8 - August]
 *  [9 - September]
 *  [10 - October]
 *  [11 - November]
 *  [12 - December]
 *
 *  @return Return the given month as a localized string
 */
+ (NSString *)monthStringWithMonthNumber:(NSInteger)month;

/**
 *  Get self as a XHLDateInformation structure
 *
 *  @return Return self as a XHLDateInformation structure
 */
- (XHLDateInformation)dateInformation;

/**
 *  Get self as a XHLDateInformation structure with a given time zone
 *
 *  @return Return self as a XHLDateInformation structure with a given time zone
 */
- (XHLDateInformation)dateInformationWithTimeZone:(NSTimeZone *)timezone;

/**
 *  Return a date from a given XHLDateInformation structure
 *
 *  @param info The XHLDateInformation to be converted
 *
 *  @return Return a NSDate from a given XHLDateInformation structure
 */
+ (NSDate *)dateFromDateInformation:(XHLDateInformation)info;

/**
 *  Return a date from a given XHLDateInformation structure with a given time
 *zone
 *
 *  @param info The XHLDateInformation to be converted
 *
 *  @return Return a NSDate from a given XHLDateInformation structure with a
 *given time zone
 */
+ (NSDate *)dateFromDateInformation:(XHLDateInformation)info
                           timeZone:(NSTimeZone *)timezone;

/**
 *  Get the given XHLDateInformation structure as a formatted string
 *
 *  @param info The XHLDateInformation to be formatted
 *
 *  @return Return a NSString in the following format:
 *  D/M/Y H:M:S
 *  Example: 15/10/2013 10:38:43
 */
+ (NSString *)dateInformationDescriptionWithInformation:(XHLDateInformation)info;

/**
 *  Add by Rain 20141230
 */
- (NSString *)date2String:(NSString *)format;

@end
